# Author:	gong_libin
# Date:		2016_06_01

CC ?= g++
CFLAGS ?= -g -Wall

GLB_ENV ?= $(shell pwd)/..
GLB_BIN ?= $(GLB_ENV)/bin
GLB_INC ?= $(GLB_ENV)/inc
GLB_LIB ?= $(GLB_ENV)/lib

GLB_GLIB ?= /usr/lib

GLBDLLTEST = GlbDllTest
GLBKEYTEST = GlbKeyTest
GLBLOGLBEST = GlbLogTest
GLBMD5TEST = GlbMd5Test
GLBMSGLBEST = GlbMsgTest
GLBPROTEST = GlbProTest
GLBSETTEST = GlbSetTest
GLBSGLBTEST = GlbSemTest
GLBSHMTEST = GlbShmTest
GLBMAPTEST = GlbMapTest
GLBRAWTEST = GlbRawTest
GLBUDPTEST = GlbUdpTest
GLBACBMTEST = GlbAcbmTest
GLBBASETEST = GlbBaseTest
GLBCODETEST = GlbCodeTest
GLBTMAPTEST = GlbTmapTest
GLBCONFTEST = GlbConfTest
GLBFILETEST = GlbFileTest
GLBLISTTEST = GlbListTest
GLBHASHTEST = GlbHashTest
GLBPIPETEST = GlbPipeTest
GLBPOOLTEST = GlbPoolTest
GLBSEMATEST = GlbSemaTest
GLBDGRAMTEST = GlbDgramTest
GLBBLOOMTEST = GlbBloomTest
GLBEPOLLTEST = GlbEpollTest
GLBMULTITEST = GlbMultiTest
GLBQUEUETEST = GlbQueueTest
GLBTHREADTEST = GlbThreadTest
GLBWORKERTEST = GlbWorkerTest
GLBSTREAMTEST = GlbStreamTest
GLBURLCODETEST = GlbUrlCodeTest

TARGETS =				\
	$(GLBDLLTEST)			\
	$(GLBKEYTEST)			\
	$(GLBLOGLBEST)			\
	$(GLBMD5TEST)			\
	$(GLBMSGLBEST)			\
	$(GLBPROTEST)			\
	$(GLBSETTEST)			\
	$(GLBSGLBTEST)			\
	$(GLBSHMTEST)			\
	$(GLBMAPTEST)			\
	$(GLBRAWTEST)			\
	$(GLBUDPTEST)			\
	$(GLBACBMTEST)			\
	$(GLBBASETEST)			\
	$(GLBCODETEST)			\
	$(GLBTMAPTEST)			\
	$(GLBCONFTEST)			\
	$(GLBLISTTEST)			\
	$(GLBFILETEST)			\
	$(GLBHASHTEST)			\
	$(GLBPIPETEST)			\
	$(GLBPOOLTEST)			\
	$(GLBSEMATEST)			\
	$(GLBDGRAMTEST)			\
	$(GLBBLOOMTEST)			\
	$(GLBEPOLLTEST)			\
	$(GLBMULTITEST)			\
	$(GLBQUEUETEST)			\
	$(GLBTHREADTEST)		\
	$(GLBWORKERTEST)		\
	$(GLBSTREAMTEST)		\
	$(GLBURLCODETEST)

OBJEGLBS =				\
	$(GLBDLLTEST).o			\
	$(GLBKEYTEST).o			\
	$(GLBLOGLBEST).o		\
	$(GLBMD5TEST).o			\
	$(GLBMSGLBEST).o		\
	$(GLBPROTEST).o			\
	$(GLBSETTEST).o			\
	$(GLBSGLBTEST).o		\
	$(GLBSHMTEST).o			\
	$(GLBMAPTEST).o			\
	$(GLBRAWTEST).o			\
	$(GLBUDPTEST).o			\
	$(GLBACBMTEST).o		\
	$(GLBBASETEST).o		\
	$(GLBCODETEST).o		\
	$(GLBTMAPTEST).o		\
	$(GLBCONFTEST).o		\
	$(GLBLISTTEST).o		\
	$(GLBFILETEST).o		\
	$(GLBHASHTEST).o		\
	$(GLBPIPETEST).o		\
	$(GLBPOOLTEST).o		\
	$(GLBSEMATEST).o		\
	$(GLBDGRAMTEST).o		\
	$(GLBBLOOMTEST).o		\
	$(GLBEPOLLTEST).o		\
	$(GLBMULTITEST).o		\
	$(GLBQUEUETEST).o		\
	$(GLBTHREADTEST).o		\
	$(GLBWORKERTEST).o		\
	$(GLBSTREAMTEST).o		\
	$(GLBURLCODETEST).o

all: $(TARGETS) install

$(OBJEGLBS): %.o: %.cpp
	$(CC) -c $(CFLAGS) -I$(GLB_INC) $< -o $@

$(TARGETS): %: %.o
	$(CC) $(CFLAGS) $< -o $@ -lglbglobal -lpthread -ldl

install:
	cp $(TARGETS) $(GLB_BIN)

clean:
	rm -rf $(TARGETS)
	rm -rf $(OBJEGLBS)
